<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 内容区域 -->
    <el-card class="box-card">
      <!-- 搜索条件 -->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入用户名搜索" v-model="queryParams.titleName">
            <template #append>
              <el-button icon="Search" @click="search(1)" />
            </template>
          </el-input>
        </el-col>
      </el-row>

      <!-- 云盘列表 -->
      <el-table :data="blogList" stripe>
        <el-table-column label="序号" type="index" width="55"> </el-table-column>
        <el-table-column prop="titleName" label="用户名" width="200"> </el-table-column>
        <el-table-column prop="author" label="密码" width="150"> </el-table-column>
        <el-table-column prop="sort" label="手机号"> </el-table-column>
        <el-table-column prop="createTime" label="头像地址"> </el-table-column>
        <el-table-column label="登录时间" width="200">
          <template v-slot="scope">
            <el-button type="primary" icon="el-icon-edit" size="small"
                       @click="handleEditDialogShow(scope.row.id)">编辑</el-button>
            <el-button type="danger" icon="el-icon-delete" size="small"
                       @click="deleteBlog(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页组件 -->
      <el-pagination background layout="total, sizes, prev, pager, next, jumper" :total="total"
                     :current-page="queryParams.pageNum" :page-sizes="[1, 5, 10]" :page-size="queryParams.pageSize"
                     @size-change="handleSizeChange" @current-change="handlePageChange" />
    </el-card>
  </div>
</template>

<script setup>
import { inject, ref } from 'vue';
import axios from '@admin/utils/request.js';
// 注入全局属性
let $message = inject('$message');
let $confirm = inject('$confirm');

/* 1: 查询博客 */
// 查询参数
const queryParams = ref({
  titleName: '',
  pageNum: 1,
  pageSize: 5
});

// 获取用户列表
const search = function () {
  axios.get('/user/getlist', {}, {fileId: 0, parentId: 0})
      .then(response => {
        id.value = [];
        pageInfo.value = response;
        blogList.value = pageInfo.value.list;
        total.value = pageInfo.value.total;
        queryParams.value.pageNum = pageInfo.value.pageNum;
      }).catch(error => {
    console.log(error);
  });
};
</script>

<style scoped>
.box-card {
  margin-top: 20px;
}

.image-preview {
  margin-top: ¼em;
}
</style>

<style scoped>
.box-card {
  margin-top: 20px;
}
</style>